import Vue from 'vue';
Vue.directive('tap',{
    bind:function(el,binding){
        var startTx, startTy,endTx,endTy;
        el.addEventListener("touchstart",function(e){
            var touch=e.touches[0];
            startTx = touch.clientX;
            startTy = touch.clientY;
            el.addEventListener("touchend",function(e){
                    var touch = e.changedTouches[0];
                    endTx = touch.clientX;
                    endTy = touch.clientY;
                    if( Math.abs(startTx - endTx) < 6 && Math.abs(startTy - endTy) < 6){
                        var method = binding.value.method;
                        var params = binding.value.params;
                        method(params);
                    }
                },false);
        },false );
        
    }
})

export {Vue}